package at.fhj.itm10.ticketmaster.entities;

import java.util.Date;

/**
 * @author 	Kevin Reinmueller
 * @since	November 2012
 */

public class Ticket implements Entity {
	
	private long id;
	private long fk_order_id;
	private long fk_events_id;
	private int quantity;
	private Date add_to_cart_date;
	
	public Ticket(long fk_order_id,	long fk_events_id, int quantity, Date add_to_cart_date) {
		this.setFk_order_id(fk_order_id);
		this.setFk_events_id(fk_events_id);
		this.setQuantity(quantity);
		this.setAdd_to_cart_date(add_to_cart_date);		
	}
	
	public Ticket() {
		// empty Constructor
	}
	
	public long getFk_order_id() {
		return fk_order_id;
	}

	public void setFk_order_id(long fk_order_id) {
		this.fk_order_id = fk_order_id;
	}

	public long getFk_events_id() {
		return fk_events_id;
	}

	public void setFk_events_id(long fk_events_id) {
		this.fk_events_id = fk_events_id;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public Date getAdd_to_cart_date() {
		return add_to_cart_date;
	}

	public void setAdd_to_cart_date(Date add_to_cart_date2) {
		this.add_to_cart_date = add_to_cart_date2;
	}

	public long getId() {
		return this.id;
	}

	public void setId(long id) {
		this.id = id;		
	}

	/**
	 * {@inheritDoc}
	 * 
	 * Returns a String with the entries from DB for Ticket.
	 * @return String
	 */
	@Override
	public String toString() {
		return "Ticket [id=" + id + ", fk_order_id=" + fk_order_id
				+ ", fk_events_id=" + fk_events_id + ", quantity=" + quantity
				+ ", add_to_cart_date=" + add_to_cart_date + "]";
	}

	/**
	 * {@inheritDoc}
	 * Returns a hashcode for the object.
	 * @return result
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	/**
	 * {@inheritDoc}
	 * 
	 * Compare this object with another object.
	 * 
	 * @param obj
	 * @return boolean (true if the objects are identical). 
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Ticket other = (Ticket) obj;
		if (id != other.id)
			return false;
		return true;
	}

}
